#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright (c) 2015  Data Enlighten Technology (Beijing) Co.,Ltd

from mj_parser.etk_parser import AudiParserETK
from mj_parser.web_parser import AudiParserWeb
from mj_parser.porsche_web_parser import PorscheWebParser
from mj_parser.ford_web_parser import FordParserWeb
from mj_parser.gm_web_parser import GmParserWeb
from mj_parser.psa_web_parser import PsaParserWeb
#from mj_parser.landrover_web_parser import LandroverWebParser
from mj_parser.bmw_web_parser import BmwWebParser

import mj_parser.common_errors
import mj_parser.win32

class ParserRegistry:
    crawler_registry = dict()

    @staticmethod
    def register(source_type, brand, parser_class):
        key = ParserRegistry.create_key(source_type, brand)
        ParserRegistry.crawler_registry[key] = parser_class

    @staticmethod
    def create_parser(source_type, brand, root_dir):
        key = ParserRegistry.create_key(source_type, brand)
        parser_class = ParserRegistry.crawler_registry.get(key, None)
        if parser_class:
            return parser_class(root_dir)
        return None

    @staticmethod
    def create_key(source_type, brand):
        return "{0}.{1}".format(source_type, brand)


ParserRegistry.register("ETK", "audi", AudiParserETK)
ParserRegistry.register("WEB", "audi", AudiParserWeb)
ParserRegistry.register("WEB", "porsche", PorscheWebParser)
ParserRegistry.register("WEB", "ford", FordParserWeb)
#ParserRegistry.register("WEB", "landrover", LandroverWebParser)
ParserRegistry.register("WEB", "psa", PsaParserWeb)
ParserRegistry.register("WEB", "gm", GmParserWeb)
ParserRegistry.register("WEB", "bmw", BmwWebParser)
